package com.VisualDisp.QuadCalculateProject.Calculations.Equations;

public class SquareEquation extends BaseEquation {

	public SquareEquation(double a, double d)
	{
		this.setA(a);
		this.setB(0);
		this.setC(d);
	}
	@Override
	public void printType() {
		System.out.println("SquareRoot Equation");
	}

	@Override
	public Result calculateExp() {
		double temp = (-c)/a;
		if(temp >= 0 )
		{
			double temp2 = Math.sqrt(temp);
			return new Result(temp2,-temp2);
		}

		return null;
	}

	@Override
	public double getA() {
		// TODO Auto-generated method stub
		return a;
	}

	@Override
	public double getB() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public double getC() {
		// TODO Auto-generated method stub
		return c;
	}

	@Override
	protected void setA(double a) {
		// TODO Auto-generated method stub
		this.a = a;
	}

	@Override
	protected void setB(double b) {
		// TODO Auto-generated method stub
		this.b = b;
	}

	@Override
	protected void setC(double c) {
		// TODO Auto-generated method stub
		this.c = c;
	}
	@Override
	public String getEquation() {
		// TODO Auto-generated method stub
		return (a+"x^2 + "+c+" = 0");
	}
	@Override
	public String getType() {
		// TODO Auto-generated method stub
		return "Square Root";
	}
	@Override
	public double calcY(double x) {
		// TODO Auto-generated method stub	
		return a*(x*x)+b*x+c;
	}

}
class TwoXSquare extends BaseEquation
{

	public TwoXSquare(double a, double b) 
	{	
		this.setA(a);
		this.setB(b);
		this.setC(0);
	}

	@Override
	public void printType() {
		System.out.println("ax^2+bx =0 Equation!");

	}

	@Override
	public Result calculateExp() {		
		return new Result(0,new LinearEquation(a, b).calculateExp().getX1());		
	}


	@Override
	public double getA() {
		// TODO Auto-generated method stub
		return a;
	}

	@Override
	public double getB() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public double getC() {
		// TODO Auto-generated method stub
		return c;
	}

	@Override
	protected void setA(double a) {
		// TODO Auto-generated method stub
		this.a = a;
	}

	@Override
	protected void setB(double b) {
		// TODO Auto-generated method stub
		this.b = b;
	}

	@Override
	protected void setC(double c) {
		this.c = c;
	}

	@Override
	public String getEquation() {
		// TODO Auto-generated method stub
		return ("x*("+a+"x"+b+") = 0");
	}

	@Override
	public String getType() {
		// TODO Auto-generated method stub
		return "Two X's";
	}

	@Override
	public double calcY(double x) {
		// TODO Auto-generated method stub
		return a*(x*x)+b*x;
	}
}
